/**
 * Created by 19610 on 2018/7/25.
 */
import axios from 'axios'
import ENV from '../ENV'
const fon = {
  install: function (Vue) {
    axios.all([getGoodsimage(), getBroadcastImage()])
      .then(axios.spread((acct, perms,userinfo)=>{
        Vue.prototype.$imgList = {
          'Goodsimage':datachuli(acct.data),
          'BroadcastImage':datachuli(perms.data),
          // 'UserinfoImg':datachuli(userinfo.data),
        }
        // 两个 请求 现在 都执行 完成
      }));
  }
};

var getGoodsimage = function () {  //获取商品图片
  return axios.get(ENV.GOODSIMAGE);
};
var getBroadcastImage = function () {//获取轮播图
  return axios.get(ENV.SOWINGMAP);
};


var datachuli = function (data) {
  let response = {};
  data.forEach(function (item) {
    let id = item.match(/[0-9]+/ig)[0];
    response[id] = item;
  });
  return response;
};
export default fon
